package com.idatax.auth.service;

import com.idatax.auth.dto.LoginRequest;
import com.idatax.auth.dto.AuthResult;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserService {

    public AuthResult authenticate(LoginRequest loginRequest) {
        Map<String, Object> claims = new HashMap<>();
        
        // 简单示例：添加用户角色和ID到claims
        if ("admin".equals(loginRequest.getUsername())) {
            claims.put("role", "ADMIN");
            claims.put("userId", 1);
            return new AuthResult(true, claims);
        }
        else if (loginRequest.getUsername() != null && 
                !loginRequest.getUsername().isEmpty() &&
                loginRequest.getPassword() != null &&
                !loginRequest.getPassword().isEmpty()) {
            claims.put("role", "USER");
            claims.put("userId", 1000);
            return new AuthResult(true, claims);
        }
        
        return new AuthResult(false, null);
    }
}
